package com.example.javanewwork.mapper;


import com.example.javanewwork.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT * FROM user")
    List<User> findAll();

    @Insert("INSERT into user(username,password,nickname,email,phone) VALUES (#{username},#{password},#{nickname},#{email},#{phone})")
    int insert(User user);

    int update(User user);

    @Select("select * from user where username like #{username} limit #{pageNum},#{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize, String username);

    @Select("select count(*) from user where username like #{username}")
    Integer selectTotal(String username);

    @Select("")
    boolean login(User user);

    @Select("select * from user where username=#{username}")
    User findUserByname(String username);

    @Insert("insert into user(username,password) values(#{username},#{password})")
    void register(String username, String password);

    @Update("update user set nickname=#{nickname},phone=#{phone},email=#{email} where username=#{username}")
    void updateUser(User user);
}
